package HOT100;

import java.util.Scanner;

/**
 * @author 是阿秋啊
 * @date 2022/09/24 16:25
 **/
public class metituan2 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String s = sc.next();
        char[] ch = s.toCharArray();
        int count = 0;
        int ret = 0;
        for (char c : ch) {
            if (c == 't') {
                count++;
            }
            if (c == 'c') {
                ret += count;
            }
        }
        System.out.println(ret);
    }
}